function IslandObject(theGame,theName,theLocation,theVisited,theLocated,theCommodities){
	var game = theGame;
	this.name = (theName==null)?(""):(theName);
	this.location = (theLocation==null)?(""):(LocationObject.clone(theLocation));
	this.visited = (theVisited==null)?(false):(theVisited!=false);
	this.located = (theLocated==null)?(false):(theLocated!=false);
	this.commodities = null;
	
	this.getName = function(){
		if(this.isVisited()){
			return this.name;
		}else{
			return game.getConfig().getUnknownIslandName();
		}
	};
	this.getLocation = function(){
		return this.location;
	};
	this.isVisited = function(){return this.visited;};
	this.setVisited = function(){this.visited = true;};
	this.isLocated = function(){return this.located;};
	this.setLocated = function(){this.located = true;};
	this.getCommodities = function(){return this.commodities;};
	this.getCommodity = function(commodity){return this.getCommodities().getCommodity(commodity);};
	
	this.clear = function(){
		this.visited = false;
		this.located = false;
		this.commodities = null;
	};
	this.generate = function(){
		this.clear();
		this.commodities = new IslandCommoditiesObject(game);
	};
}
function IslandsObject(theGame){
	var game = theGame;
	this.islands = {};
	this.clear = function(){
		this.islands = {};
	};
	this.getIsland = function(island){
		return this.islands[island];
	};
	this.getIslandList = function(){
		var result = [];
		for(var island in this.islands){
			result.push(island);
		}
		return result;
	};
	var generateRandomName = function(){
		var length = game.getUtilities().getRandomInt(game.getConfig().getMinimumNameLength(),game.getConfig().getMaximumNameLength());
		var result="";
		var vowel= (game.getUtilities().getRandomBoolean());
		while(result.length<length){
			var letter;
			if(vowel){
				letter = game.getConfig().getVowel(game.getUtilities().getRandomInt(0,game.getConfig().getVowelCount()-1));
			}else{
				letter = game.getConfig().getConsonant(game.getUtilities().getRandomInt(0,game.getConfig().getConsonantCount()-1));
			}
			if(result.length==0){
				result += letter.toUpperCase();
			}else{
				result += letter;
			}
			vowel=!vowel;
		}
		return result;
	};
	var generateRandomLocation = function(){
		return new LocationObject(
			game.getUtilities().getRandomFloat(game.getConfig().getMinimumIslandX(),game.getConfig().getMaximumIslandX()),//x
			game.getUtilities().getRandomFloat(game.getConfig().getMinimumIslandY(),game.getConfig().getMaximumIslandY()));//y
	};
	this.generate = function(){
		this.clear();
		
		var names = [];
		while(names.length<game.getConfig().getIslandCount()){
			var randomName = generateRandomName();
			for(var index=0;index<names.length;++index){
				if(names[index]==randomName) break;
			}
			if(index==names.length){
				names.push(randomName);
			}
		}
		
		var locations = [];
		while(locations.length<game.getConfig().getIslandCount()){
			var location = generateRandomLocation();
			for(var index=0;index<locations.length;++index){
				if(locations[index].getDistanceBetween(location)<game.getConfig().getMinimumIslandDistance()) break;
			}
			if(index==locations.length){
				locations.push(location);
			}
		}
		
		for(var index=0;index<game.getConfig().getIslandCount();++index){
			this.islands[names[index]] = new IslandObject(game,names[index],locations[index]);
			this.islands[names[index]].generate();
		}
		
	}
	this.findNearestIsland = function(location){
		var islandList = this.getIslandList();
		var nearestIsland = islandList[0];
		var smallestDistance = location.getDistanceBetween(this.getIsland(islandList[0]).getLocation());
		for(var index=1;index<islandList.length;++index){
			var island = this.getIsland(islandList[index]);
			if(location.getDistanceBetween(island.getLocation())<smallestDistance){
				nearestIsland = islandList[index];
				smallestDistance = location.getDistanceBetween(island.getLocation());
			}
		}
		return nearestIsland;
	};
	this.getGameData = function(){
		return {};
	};
	this.setGameData = function(data){
	};

}
